package com.candoit.webapps.pricing.bean.adapters;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import com.candoit.webapps.pricing.model.Linea;
import com.candoit.webapps.pricing.model.TipoLinea;
import com.candoit.webapps.pricing.util.QueryUtil;

public class MyLineaConverter implements Converter {

	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		if (value != null){
			Linea l = (Linea)value;
			return l.getNombre();
		}else{
			return null;
		}
	}

	public Object getAsObject(FacesContext context, UIComponent component,
			String value) {
		Linea l = QueryUtil.getInstance().getLineaByName(value);
		return l;
	}

}
